common={
	initCatalogueMagePage:function(){
		this.Authorization= window.localStorage.getItem("auth_token") || '';
		// 绑定dom对象
		this.obj = {
			searchText:$('#searchText'),
		};
		// 声明全局变量
		this.vars = {
			datatable:[],
			searchTable:{
				owersName:"",
				platformName:"",
				terminalType:"",
				terminalNo:"",
				page:1,
				size:10,
			},
		};
		this.ajaxtable();
		this.btnEvent();

	},
	tableEvent:function(id,data,columns,paginationShow,total){
		var self=this;
		$('#' + id).bootstrapTable({
			method: 'get',
			cache: false,
			height: 430,
			pagination: paginationShow,
			pageSize: self.vars.searchTable.size,
			pageNumber:self.vars.searchTable.page,
			showColumns: true,
			striped: true,
			columns: columns,
			data :data,
			sidePagination: 'server',
			totalRows: total,
			onPageChange: function (size, number) {
				console.log(size)
				console.log(number)
				self.vars.searchTable.size=size;
				self.vars.searchTable.page=number;
				self.ajaxtable()
			},
			formatNoMatches: function(){
				return '无符合条件的记录';
			}
		});
	},
	creatTable:function(res){
		var self=this;
		var columnsOne = [
			{
				field: 'id',
				title: '序号',
				align: 'center',
				formatter: function (value, row, index) {
					var pageSize=self.vars.searchTable.size;
					var pageNumber=self.vars.searchTable.page;
					return pageSize * (pageNumber - 1) + index + 1;
				}
			},
			{
				field: 'terminalNo',
				title: '终端编号',
			},
			{
				field: 'vehicleNo',
				title: '车牌号',
			},
			{
				field: 'owersName',
				title: '企业',
			},
			{
				field: 'platformName',
				title: '平台',
			},
			{
				field: 'terminalId',
				title: '厂商编号',
			},
			{
				field: 'terminalType',
				title: '终端型号',
			},
			{
				field: 'simCode',
				title: 'SIM卡号',
			},
			{
				field: 'macFlag',
				title: 'MAC地址上传状态',
			},
			{
				field: 'binding',
				title: '绑定状态',
			},
			{
				field: 'verifyFlag',
				title: '安装状态',
			},
			{
				field: 'createTime',
				title: '创建时间',
			},
			{
				field: 'verifyTime',
				title: '安装日期',
			}
		];
		self.tableEvent("check_detail",res.data,columnsOne,true,res.total);
	},
	ajaxtable:function(){
		var self=this;
		jrequest.get(urls.zongduan,self.vars.searchTable).then(res => {
			console.log("123",res)
			self.vars.datatable = res.data;
			$('#check_detail').bootstrapTable('destroy');
			self.creatTable(res)
		})
	},
	btnEvent:function(){
		var self=this;
		$(".search-div .j-search-btn button").eq(0).click(function(){
			self.vars.searchTable.platformName=$(".j-search-row .item").eq(0).find("input").val();
			self.vars.searchTable.owersName=$(".j-search-row .item").eq(1).find("input").val();
			self.vars.searchTable.terminalType=$(".j-search-row .item").eq(2).find("input").val();
			self.vars.searchTable.terminalNo=$(".j-search-row .item").eq(3).find("input").val();
			self.vars.searchTable.page=1;
			self.vars.searchTable.size=10;
			self.ajaxtable()
		});
		$(".search-div .j-search-btn button").eq(1).click(function(){
			$(".j-search-row .item").eq(0).find("input").val("");
			$(".j-search-row .item").eq(1).find("input").val("");
			$(".j-search-row .item").eq(2).find("input").val("");
			$(".j-search-row .item").eq(3).find("input").val("");
			self.vars.searchTable.platformName="";
			self.vars.searchTable.owersName="";
			self.vars.searchTable.terminalType="";
			self.vars.searchTable.terminalNo="";
			self.vars.searchTable.page=1;
			self.vars.searchTable.size=10;
			self.ajaxtable()
		})
	}
}

$(function(){
	common.initCatalogueMagePage();
});